package com.itheima.dao;

import com.itheima.POJO.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface ordersettingMapper {

    /**
     * 根据预约日期查询预约管理数据
     */
    @Select("select * from t_ordersetting where orderDate = #{orderDate}")
    OrderSetting selectOrderSettingByOrderDate(Date orderDate);

    /**
     * 更新预约管理数据
     */
    @Update("update t_ordersetting\n" +
            "        set\n" +
            "            number = #{number},reservations = #{reservations}\n" +
            "        where\n" +
            "            orderDate =#{orderDate}")
    void updateOrderSetting(OrderSetting orderSetting);


    /**
     * 保存可预约时间和可预约人数到ordersetting数据库
     *
     */
    @Insert("insert into t_ordersetting (orderDate,number,reservations) values (#{orderDate},#{number},#{reservations})")
    public void addOrdersetting3orderDateAndnumber(OrderSetting orderSetting);

    /**
     * 去数据库中查询 是否有该预约时间
     */
    @Select("select count(*) from t_ordersetting where orderDate = #{orderDate}")
    Integer findOrderdataFromordersetting(Date orderDate);


    /**
     * 更新预约时间
     * @param orderSetting
     */
    @Update("update t_ordersetting set number = #{number} where orderDate = #{orderDate}")
    public void editNumber4OderData4Ordersetting(OrderSetting orderSetting);


   /* @Select("SELECT orderDate AS DATE,number,reservations  FROM t_ordersetting WHERE orderDate BETWEEN #{bagin} AND #{end}")
    List<Map> findOrdersettingBydata(@Param("bagin") String bagin,@Param("end") String end);*/


    @Select("select * from t_ordersetting where orderDate between #{bagin} and #{end}")
    List<OrderSetting> findOrdersettingBydata(@Param("bagin") String bagin,@Param("end") String end);


}
